from os.path import dirname, join

# ---测试账户 sit/uat 共用---
USERNAME = "13687428237"
PASSWORD = "admin123"

# ---项目地址---
# sit 环境
SIT_DIM_URL = "https://ssoi-sit.newpearl.com/#/login?systemType=DIM"
# uat 环境
UAT_DIM_URL = "https://ssoi-uat.newpearl.com/#/login?systemType=DIM"

# ---业务相关URL地址---
# sit 环境
# 采购合同列表页 URL
SIT_PURCHASE_CONTRACT_LIST_URL = "https://scm-sit.newpearl.com/#/scmPurchaseContractH"
# 采购合同新增 URL
SIT_PURCHASE_CONTRACT_ADD_URL = (
    "https://scm-sit.newpearl.com/#/scmPurchaseContractH/add"
)
# 采购合同编辑：如果合同状态为 有效，则为合同变更，需要传入 合同单号
SIT_PURCHASE_CONTRACT_EDIT_URL = (
    "https://scm-sit.newpearl.com/#/scmPurchaseContractH/edit/{}"
)
# 采购合同详情页
SIT_PURCHASE_CONTRACT_DETAIL_URL = (
    "https://scm-sit.newpearl.com/#/scmPurchaseContractH/text/{}"
)
# 申购单列表页 URL
SIT_SCM_APPLY_PURCHASE_LIST_URL = "https://scm-sit.newpearl.com/#/scmApplyPurchaseList"
# 申购单新增 URL
SIT_SCM_APPLY_PURCHASE_ADD_URL = (
    "https://scm-sit.newpearl.com/#/scmApplyPurchaseEdit?execType=add"
)
# 申购单详情页 URL
SIT_SCM_APPLY_PURCHASE_DETAIL_URL = (
    "https://scm-sit.newpearl.com/#/scmApplyPurchaseEdit?orderNo={}&execType=search"
)
# 待审批申购单列表 URL，化工业务申购单审批
SIT_ADD_APPROVAL_PENDING_APPLY_PURCHASE_LIST_URL = (
    "https://scm-sit.newpearl.com/#/scmAddApprovalPendingApplyPurchaseList"
)
# 待处理请求列表页 URL
SIT_SCM_PEND_REQUESTS_URL = "https://scm-sit.newpearl.com/#/scmPendrequests"
# 采购订单列表页面 URL
SIT_SCM_PURCHASE_ORDER_LIST_URL = "https://scm-sit.newpearl.com/#/scmPoH"
# B2B采购订单列表页面 URL
SIT_B2B_PURCHASE_ORDER_LIST_URL = "https://scm-sit.newpearl.com/#/puB2bPoD"
# B2B待发货订单列表页面 URL
SIT_B2B_DELIVER_LIST_URL = "https://scm-sit.newpearl.com/#/puB2bDeliver"

# uat 环境
# 采购合同列表页 URL
UAT_PURCHASE_CONTRACT_LIST_URL = "https://scm-uat.newpearl.com/#/scmPurchaseContractH"
# 采购合同新增 URL
UAT_PURCHASE_CONTRACT_ADD_URL = (
    "https://scm-uat.newpearl.com/#/scmPurchaseContractH/add"
)
# 采购合同编辑：如果合同状态为 有效，则为合同变更，需要传入 合同单号
UAT_PURCHASE_CONTRACT_EDIT_URL = (
    "https://scm-uat.newpearl.com/#/scmPurchaseContractH/edit/{}"
)
# 申购单列表页 URL
UAT_SCM_APPLY_PURCHASE_LIST_URL = "https://scm-uat.newpearl.com/#/scmApplyPurchaseList"
# 申购单新增 URL
UAT_SCM_APPLY_PURCHASE_ADD_URL = (
    "https://scm-uat.newpearl.com/#/scmApplyPurchaseEdit?execType=add"
)
# 待审批申购单列表 URL，化工业务申购单审批
UAT_ADD_APPROVAL_PENDING_APPLY_PURCHASE_LIST_URL = (
    "https://scm-uat.newpearl.com/#/scmAddApprovalPendingApplyPurchaseList"
)
# 待处理请求列表页 URL
UAT_SCM_PEND_REQUESTS_URL = "https://scm-uat.newpearl.com/#/scmPendrequests"
# 采购订单列表页面 URL
UAT_SCM_PURCHASE_ORDER_LIST_URL = "https://scm-uat.newpearl.com/#/scmPoH"
# B2B采购订单列表页面 URL
UAT_B2B_PURCHASE_ORDER_LIST_URL = "https://scm-uat.newpearl.com/#/puB2bPoD"
# B2B待发货订单列表页面 URL
UAT_B2B_DELIVER_LIST_URL = "https://scm-uat.newpearl.com/#/puB2bDeliver"


# ---项目包及文件夹路径---
# 项目根目录
BASE_PATH = dirname(__file__)
# 浏览器驱动地址(根据实际部署配置)
CHROME_DRIVER_PATH = join(
    BASE_PATH, "dim_web_auto_test/browser_driver/chromedriver.exe"
)
# 导入文件夹路径（需要根据部署环境修改）
UPLOAD_FILE_PATH = join(BASE_PATH, "dim_web_auto_test/files")
# 数据库配置文件路径
DATABASE_INI_PATH = join(BASE_PATH, "config/database.ini")

# ---浏览器对象属性---
# 无头化
HEADLESS = False
# 浏览器窗口大小
WINDOWS_SIZE = (1440, 760)
# 隐式等待时间
IMP_TIME = 15
# 页面加载时间
PAGE_LOAD_TIME = 10
# JS 执行时间
SCRIPT_TIME_OUT = 10

# ---chrome 浏览器属性---
# 浏览器操作开关
CHROME_METHOD_MARK = True
# 启动参数开关
CHROME_OPTION_MARK = True
# 实验性质启动参数
CHROME_EXPERIMENTAL = {
    "excludeSwitches": ["enable-automation"],  # 消除受到自动测试软件的控制的提示
    # "mobileEmulation": {"deviceName": "iPhone X"}  # H5页面测试需要添加，正常 web 自动化测试无需添加
}
# 启动最大化参数
CHROME_START_MAXIMIZED = "-start-maximized"

# ---yaml 元素配置文件---
# 元素文件配置根目录
ELEMENT_YAML_FILE_PATH = join(BASE_PATH, "dim_web_auto_test/page_element")
YAML_ELEMENT = {
    # 登录页
    "login_page": join(ELEMENT_YAML_FILE_PATH, "login_page.yml"),
    # 采购合同列表页
    "pc_list_page": join(ELEMENT_YAML_FILE_PATH, "purchase_contract_list_page.yml"),
    # 采购合同详情页
    "pc_detail_page": join(ELEMENT_YAML_FILE_PATH, "purchase_contract_detail_page.yml"),
    # 申购单详情页
    "pc_apply_detail_page": join(ELEMENT_YAML_FILE_PATH, "pc_apply_page.yml"),
}

# ---selenium 支持的元素定位方法---
BY_RULES = {
    "id",
    "xpath",
    "link text",
    "partial link text",
    "name",
    "tag name",
    "class name",
    "css selector",
}

if __name__ == "__main__":
    print(YAML_ELEMENT)
